home *** CD-ROM | disk | FTP | other *** search
/ Just Call Me Internet / Just Call Me Internet.iso / prog / mint / duftp / local_fs.c < prev    next >
Text File  |  1995-06-13  |  2KB  |  97 lines

  1. /*
  2.     DUFTP
  3. */
  4.  
  5. // Local Filesystem Handling
  6.  
  7. #include <DULIB.H>
  8. #include <MINTBIND.H>
  9. #include <FILESYS.H>
  10. #include <ERRNO.H>
  11. #include "globals.h"
  12. #include "ls2filel.h"
  13. #include "local_fs.h"
  14.  
  15. // get a directory listing from the current local directory
  16.  
  17. void get_local_files(void)
  18. {
  19.     char dirbuf[FMSIZE],*fname;
  20.     char cdir[FMSIZE];
  21.     char namebuf[FMSIZE];
  22.     XATTR a;
  23.     short f;
  24.     file_list *nf;
  25.     long dhandle,r;
  26.     
  27.     if (local_directory) dispose_file_list(local_directory);
  28.     
  29.     fname=dirbuf+4;
  30.     
  31.     sprintf(cdir,"%s",current_local_path);
  32.     for(f=0; f<FMSIZE; f++) if (cdir[f]=='/') cdir[f]='\\';
  33.     
  34.     dhandle=Dopendir(cdir,0);
  35.     
  36.     if ((dhandle&0xFF000000)==0xFF000000)
  37.     {
  38.         dhandle=dhandle&0xFF;
  39.         if (dhandle==EPATH)
  40.         {
  41.             printf("Invalid path\n");
  42.             return;
  43.         }
  44.         if (dhandle==EACCESS)
  45.         {
  46.             printf("Directory not accessible\n");
  47.             return;
  48.         }
  49.         if (dhandle==ENOMEM)
  50.         {
  51.             printf("Kernal is out of memory\n");
  52.             return;
  53.         }
  54.         return;
  55.     }
  56.     local_directory=NULL;
  57.     graf_mouse(HOURGLASS,NULL);
  58.     while(Dreaddir(FMSIZE,dhandle,dirbuf)==0)
  59.     {
  60.         if (!((fname[0]=='.')&&(fname[1]=='\0'))
  61.             &&(!((fname[0]=='.')&&(fname[1]=='.'))))
  62.         {
  63.             sprintf(namebuf,"%s\\%s",cdir,fname);
  64.             r=Fxattr( 0, namebuf, &a);
  65.             nf=(file_list*)malloc(sizeof(file_list));
  66.         
  67.             nf->size=a.size;
  68.             
  69.             if ((a.mode&S_IFMT)==S_IFDIR)
  70.             {
  71.                 sprintf(nf->name," %s",fname,a.size);
  72.                 nf->is_directory=TRUE;
  73.             }else{
  74.                 sprintf(nf->name,"  %s (%d)",fname,a.size);
  75.                 nf->is_directory=FALSE;
  76.             }
  77.             
  78.             if ((a.mode&S_IFMT)==S_IFLNK)
  79.             {
  80.                 nf->name[1]='';
  81.                 nf->is_symlink=TRUE;
  82.             }else{
  83.                 nf->is_symlink=FALSE;
  84.             }
  85.             
  86.             nf->owner_read=TRUE;
  87.             nf->public_read=TRUE;
  88.             sprintf(nf->owner,"root");
  89.             nf->next=local_directory;
  90.             local_directory=nf;
  91.         }
  92.     }
  93.     
  94.     graf_mouse(ARROW,NULL);
  95.     Dclosedir(dhandle);
  96. }
  97.